<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    
    class Parent{
        constructor(msg){
            this.msg = msg;
        }
        show(){
            console.log(this.msg);
        }
    }

    class Child extends Parent{
        constructor(msg){
            super(msg);
        }
    }

    const p = new Parent("hello")
    console.log(p)
    p.show();

    const c = new Child("world");
    console.log(c)
    c.show();

    console.log("=====")


    function myParent(msg){
        this.msg = msg;
        this.show = function(){
            console.log(this.msg)
        }
    }
    myParent.prototype.init = function(){
        console.log("这是init", this.msg);
    }


    function extend(Parent){
        function Child(msg){
            Parent.call(this, msg)
        }
        Child.prototype.__proto__ = Parent.prototype;
        return Child;
    }

    const myChild = extend(myParent);
    const myc = new myChild("world");
    console.log(myc);


</script>
</html>